﻿<Select Mode="multiple"
        Id="selectDemoMaxTag"
        Placeholder="Please select"
		@bind-Values="@_selectedValues"
		TItemValue="string"
		TItem="string"
		OnSelectedItemsChanged="OnSelectedItemsChangedHandler"
		Style="width: 100%; margin-bottom: 8px;"
        MaxTagCount="@_tagCount"
		EnableSearch
		AllowClear>
		<SelectOptions>
			@foreach(var item in _items)
			{
				<SelectOption TItemValue="string" TItem="string" Value=@item Label=@($"Long label: {item}") />
			}
		</SelectOptions>
</Select>
<Text>MaxTagCount</Text>
<AntDesign.InputNumber @bind-Value="@_tagCount"/>
@code
{
    List<string> _items;
    IEnumerable<string> _selectedValues;
	int _tagCount = 2;

	protected override void OnInitialized()
    {
        const int min = 10;
        const int max = 36;
        _items = new List<string>();

        for (var i = min; max > i; i++)
        {
            var value = Convert.ToString(i, 16).PadLeft(2, '0') + i.ToString();
            _items.Add(value);
        }

		_selectedValues = new List<string> { "0a10" , "0c12", "0h17", "1117", "1824", "0d13"};
    }

    private void OnSelectedItemsChangedHandler(IEnumerable<string> values)
    {
		if (values != null)
			Console.WriteLine($"selected: ${string.Join(",", values)}");
    }
}